<?php
include_once 'CF_TableEdInline.php';

// define custom class -------------------------------------------------------------------------
	class CF_MultiFormDiv extends CF_TableEdInline {
		// set the row limit for this class
		//var $default_row_limit = 100;
	
	// Override table to make a multi-form
	
		//var $filtersprefix = '';
		var $multisel_text = 'Select';
	
	function make_rowval($value,$column){
		
		//$chgname = "chg_$column" . "()";
		
		$row_text .= "<label for='$column' >";
		(isset($this->fieldspec[$column]['headname']))?$row_text .= $this->fieldspec[$column]['headname']:$row_text .= $column;
        $row_text .= "</label> \n " . $this->make_valuebox($value,$column);

		//$row_text .= "</div> <!-- end fment_$column -->";
		return $row_text;
			
	}
	
	 /**
 * function to make start of row, making each row a form for editing
 * @param int $row_num This is the row number of the dataset
 * @param string $key_string This is the string of key values, defined by make_key_string function
 * @return string Row begining 
 */
	function make_row_start($row_num){
		$formname = $this->tablename . '_' . $this->keys_uid;
		$rowstart .= "<form action='$this->actionpage' name='$formname' id='$formname' method='GET'>\n<fieldset>\n";
		$rowstart .= "<legend>$this->formlegend</legend>\n";
		$rowstart .= $this->keys_hidden . "\n";
		

		
		if($this->multiselect){
			$rowstart .=  "<label>$this->multisel_text</label>\n" . $this->make_multiselectCB();
		}		
		
		
		
		return $rowstart;
	}


	function make_row_end($row_num){
	//$rowend .= "<div class='fmctls' >";
	$rowend .= "<input class='mode' type='hidden' name='mode' value='Save Row' \>";
	$rowend .= "<input class='mode'  type='button' value='Save Row' onClick=\"return validateForm(this.form)\" />";
	$rowend .= "<input class='mode' type='submit' name='mode' value='Delete' onClick=\"return confirm('Do you really want to delete?')\" />";

	//$rowend .= "</div> <!-- end fmctls --> \n";
	$rowend .= "</fieldset> <!-- end form fieldset -->\n</form>\n";
		
		return $rowend;
	}

/**
	 *
     * make_element_div_set set will create a set of div for use as a form
     * from an input of an element_set array.  Each row has element_name and value
     * @param array elements An array with [body] and [head] parts where head
     * elements['head'] is the title and elements['body'] is what to put in the cell
     * @param string $headset Settings for heading elements (class name, etc)
     * @param string $bodyset Settings for body elemetns (class naem, etc)
     * @param string $id Settings for name of the div set
	 *
	 */
    function make_element_div_set($elements, $headset, $bodyset){
        foreach ($elements AS $name=>$current){
            $outtext .= "<div id='entry_$name' class='entries'>\n";
            foreach($current AS $key=>$value){

                $outtext .= "<div class='$key'>\n $value </div>\n";
                }
            $outtext .= "</div>\n";
         }

        return $outtext;
    }	
	
	}
?>